package com.gxuwz.library_consumer.service;

import com.github.pagehelper.PageInfo;
import com.gxuwz.commonmodule.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Component
@FeignClient(value = "user-provider")
public interface UserService {
    /**
     * 添加用户信息
     * @param entity
     */
    @PostMapping("/add")
    public void insert(@RequestBody User entity);

    /**
     * 通过username删除用户信息
     * @param username
     */
    @DeleteMapping("/delete/{username}")
    public void deleteUser (@PathVariable("username")String username);

    /**
     * 更新用户信息
     * @param user
     */
    @PutMapping("/update")
    public void updateUser(@RequestBody User user);

    /**
     * 通过username 查询用户信息
     * @param username
     * @return
     */
    @GetMapping("/findById/{username}")
    public User findById(@PathVariable("username")String username);

    /**
     * 查询所有用户信息
     * @param user
     * @return
     */
    @GetMapping("/list")
    public List<User> list(@RequestBody User user);

    /**
     * 修改用户信息
     * @param username
     * @return
     */
    @GetMapping("/{username}")
    public User findInfo(@PathVariable("username") String username);

    /**
     * 分页查询用户信息
     * @param pageIndex
     * @param pageSize
     * @return
     */
    @GetMapping("/findPage")
    PageInfo findPage(@RequestParam(value = "pageIndex") int pageIndex,@RequestParam(value = "pageSize") int pageSize);
}
